﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace katOS
{
    class Process
    {
        int pid;    //Process ID
        int ip;     //Instruction pointer
        int state;  //Process state
        int pvalue; //value thar returns after ending a process
        int r0, r1, r2, r3, r4, r5, r6, r7;
        volatile string file_name = "";
        LinkedList<String> instructions_set;
        volatile string[,] symbolsTable;

        //check for variables for sync and async process

        public Process(string name, int id)
        {
            pid = id;
            file_name = name;
            r0 = r1 = r2 = r3 = r4 = r5 = r6 = r7 = pvalue = 0;
        }

        public Process()
        {
            r0 = r1 = r2 = r3 = r4 = r5 = r6 = r7 = pvalue = 0;
        }

        public void setProcessValue(int value)
        {
            pvalue = value;
        }

        public int getProcessValue()
        {
            return pvalue;
        }

        public string getFileName()
        {
            return file_name;
        }

        public void setRegister(string reg_name, int reg)
        {
            switch (reg_name)
            {
                case "r0":
                    r0 = reg;
                    break;
                case "r1":
                    r1 = reg;
                    break;
                case "r2":
                    r2 = reg;
                    break;
                case "r3":
                    r3 = reg;
                    break;
                case "r4":
                    r4 = reg;
                    break;
                case "r5":
                    r5 = reg;
                    break;
                case "r6":
                    r6 = reg;
                    break;
                case "r7":
                    r7 = reg;
                    break;
                default:
                    Console.WriteLine("Not a register");
                    break;
            }
        }

        public int getRegister(string reg_name)
        {
            switch (reg_name)
            {
                case "r0":
                    return r0;
                case "r1":
                    return r1;
                case "r2":
                    return r2;
                case "r3":
                    return r3;
                case "r4":
                    return r4;
                case "r5":
                    return r5;
                case "r6":
                    return r6;
                case "r7":
                    return r7;
                default:
                    Console.WriteLine("Not a register");
                    return -1;
            }
        }

        public void setIP(int ip)
        {
            this.ip = ip;
        }

        public int getIP()
        {
            return ip;
        }

        public void setState(int state)
        {
            this.state = state;
        }

        public int getState()
        {
            return state;
        }

        public void setInstructions(LinkedList<String> insts)
        {
            instructions_set = insts;
        }

        public LinkedList<String> getInstructions()
        {
            return instructions_set;
        }

        public void setSymbolsTable(string[,] stable)
        {
            symbolsTable = stable;
        }

        public string[,] getSymbolsTable()
        {
            return symbolsTable;
        }


    }
}